﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Sherwood.SignOn.Server.Models.Repositories;
using Sherwood.SignOn.Server.Models.Services;

namespace Sherwood.SignOn.Server.Tests.DummyRoleProvider
{
    public class SourceBRoleProvider : IProfileProvider
    {
        #region IRoleProvider Members

        public void GetRoles(IUserSession session, string requestClientCode, out RoleInfo[] roles, out AttributeInfo[] attributes)
        {
            IUserAccount userAccount = null;
            if (session != null && session.UserAccount != null)
            {
                userAccount = session.UserAccount;
            }
            GetRoles(userAccount, requestClientCode, out roles, out attributes);
        }

        public void GetRoles(IUserAccount userAccount, string requestClientCode, out RoleInfo[] roles, out AttributeInfo[] attributes)
        {
            List<RoleInfo> roleList = new List<RoleInfo>();
            List<AttributeInfo> attributeList = new List<AttributeInfo>();
            if (userAccount != null)
            {
                roleList.Add(new RoleInfo { Name = "RoleA", Source = "SourceB" });
                roleList.Add(new RoleInfo { Name = "RoleB", Source = "SourceB" });
                attributeList.Add(new AttributeInfo { Name = "AttributeA", Source = "SourceB", Value = "1" });
                attributeList.Add(new AttributeInfo { Name = "AttributeB", Source = "SourceB", Value = "2" });
            }
            roles = roleList.ToArray();
            attributes = attributeList.ToArray();
        }

        #endregion
    }
}
